home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 027a / cbutton.zip / PE.PRG < prev    next >
Text File  |  1991-10-24  |  3KB  |  148 lines

  1. /*
  2.  * pe.prg
  3.  *
  4.  * Taylor Data Services
  5.  *
  6.  * Placed into the Public Domain
  7.  *
  8.  */
  9.  
  10.  
  11. #include "setcurs.ch"
  12. #include "getexit.ch"
  13. #include "pe.ch"
  14.  
  15. #define K_SPACE 32
  16.  
  17. static PE_0
  18. static PE_1
  19.  
  20.  
  21.  
  22.  
  23. function PEAdd(nType, cName, cVBlock, nGetRow, nGetCol,;
  24.                       cPict, bValid, bWhen, cColor, xCargo)
  25.  
  26. local oGet := GetNew(nGetRow, nGetCol, cVBlock, cName, cPict, cColor)
  27.  
  28.  
  29. cColor := if(ValType(cColor) == "C", cColor, SetColor())
  30.  
  31. if ( ValType(oGet) == "O" )
  32.     if ( ValType(bValid) == "B" )
  33.         oGet:postBlock := bValid
  34.     endif
  35.  
  36.     if ( ValType(bWhen) == "B" )
  37.         oGet:preBlock := bWhen
  38.     endif
  39.  
  40.     oGet:reader := {|PE_1| PEReader(PE_1) }
  41.     
  42.     if ( nType == PE_BUTTON )
  43.         oGet:Cargo := { PE_BUTTON, xCargo }
  44.     endif
  45. endif
  46.  
  47. return (oGet)
  48.  
  49.  
  50.  
  51.  
  52.  
  53. static function PEReader(oGet)
  54.  
  55. local nType  := 0
  56. local aCargo := {}
  57. local nHKey  := 0
  58. local nKey   := 0
  59. local cKey   := ''
  60. local t      := ""
  61.  
  62.  
  63. if ( ValType(oGet:cargo) != "A" )
  64.     GetReader(oGet)
  65. else
  66.     nType  := oGet:cargo[PE_TYPE]
  67.     aCargo := oGet:cargo[PE_CARGO]
  68.  
  69.     oGet:exitState := GE_NOEXIT
  70.  
  71.     if ( nType == PE_BUTTON )
  72.         oGet:setFocus()
  73.  
  74.         if ( GetPreValidate(oGet) )
  75.             while ( oGet:exitState == GE_NOEXIT )
  76.                 while ( oGet:exitState == GE_NOEXIT )
  77.                     nKey := Inkey(0)
  78.  
  79.                     cKey := Chr(nKey)
  80.  
  81.                     do case
  82.                         case cKey $ "YyTtXx"
  83.                             oGet:varPut(aCargo[PE_B_ON])
  84.                             oGet:updateBuffer()
  85.  
  86.                         case cKey $ "NnFf"
  87.                             oGet:varPut(aCargo[PE_B_OFF])
  88.                             oGet:updateBuffer()
  89.  
  90.                         case nKey == K_SPACE
  91.                             oGet:varPut(if(oGet:varGet() == aCargo[PE_B_ON],;
  92.                                            aCargo[PE_B_OFF], aCargo[PE_B_ON]))
  93.  
  94.                             oGet:updateBuffer()
  95.  
  96.                         case nKey < 32 .or. nKey > 255
  97.                             GetApplyKey(oGet, nKey)
  98.  
  99.                     endcase
  100.                 enddo
  101.  
  102.                 if ( !GetPostValidate(oGet) )
  103.                     oGet:exitState := GE_NOEXIT
  104.                 endif
  105.             enddo
  106.         endif
  107.  
  108.         oGet:killFocus()
  109.     endif
  110. endif
  111.  
  112. return (NIL)
  113.  
  114.  
  115.  
  116.  
  117.  
  118. static function PE_CheckWhen(oGet)
  119.  
  120. if ( ValType(oGet:preBlock) == "B" )
  121.     oGet:exitState := if(Eval(oGet:preBlock, oGet), GE_NOEXIT, GE_WHEN)
  122. endif
  123.  
  124. return (oGet:exitState == GE_NOEXIT)
  125.  
  126.  
  127.  
  128.  
  129.  
  130. function PE_ShowGet(oGet)
  131.  
  132. local nType
  133. local aCargo
  134.  
  135. if ( ValType(oGet:cargo) != "A" )
  136.     oGet:display()
  137. else
  138.     nType  := oGet:cargo[PE_TYPE]
  139.     aCargo := oGet:cargo[PE_CARGO]
  140.  
  141.     if ( nType == PE_BUTTON )
  142.         oGet:display()
  143.     endif
  144. endif
  145.  
  146. return (NIL)
  147.  
  148.